let app = getApp();
import {util} from '../../utils/util';

Component({
    options: {
        addGlobalClass: true
    },
    mixins: [],
    data: {
        reject_Boolean: true,
        select: false,
        input_Boolean: true,
        screenYesOrNo: false,  //点击筛选后提示的筛选条件框
        reason: '',
        grade_name: '--请选择--',
        grades: ['信息不符，给予退回', '信息不符评价项，给予退回', '图片信息不清晰，请重新提交', '资料不全，给予退回', '其他'],
        rejectTypeIndex: -1,//grades数组选中元素的下标
        dealType: '',   //处理类型，（1确认，2驳回）
        instanceId: 0,   //实例id
        exampleListIndex: -1,  //处理的实例下标
        bh_id: 0,//处理时驳回的id
        activityType: '0',//筛选时的活动类型
        instanceType: '0',//筛选时的实例类型
        activityTypeString: '全部',//筛选时的活动类型String
        instanceTypeString: '全部',//筛选时的活动   默认为全部
        page: 1,              //页码，默认1
        pageSize: 10,         //每页个数，默认20
        loadBoolean: true,   //底部的加载更多按钮
        //实例集合
        exampleList: [],
        listHide: 0,
        examoleSearchList: [],
        examoleSearchListIndex: -1,//搜索后list中的选择处理元素的下标

        filterModal: {
            show: false
        },
        searchModal: {
            show: false
        },
        //活动类型名称数组    活动类型显示的子类和选中时的样式
        instanceTypeArr: [
            {css: 'active', name: '全部', activityType: '0'}, {css: '', name: '思想品德', activityType: '1'}, {
                css: '',
                name: '学业水平',
                activityType: '2'
            },
            {css: '', name: '身心健康', activityType: '3'}, {css: '', name: '艺术素养', activityType: '4'}, {
                css: '',
                name: '社会实践',
                activityType: '5'
            }, {css: '', name: '特色项目', activityType: '6'}
        ],

        sxpdArr: [
            {name: '', css: 'active', value: '全部', instanceType: '0'}, {
                name: '',
                css: '',
                value: '党团活动',
                instanceType: '110'
            }, {name: '', css: '', value: '社团活动', instanceType: '111'},
            {name: '', css: '', value: '公益劳动', instanceType: '112'}, {
                name: '',
                css: '',
                value: '志愿服务',
                instanceType: '113'
            }, {name: '', css: '', value: '个人荣誉', instanceType: '114'},
            {name: '', css: '', value: '不良记录', instanceType: '115'}, {
                name: '',
                css: '',
                value: '其他',
                instanceType: '116'
            }
        ],
        xyspArr: [
            {name: '', css: 'active', value: '全部', instanceType: '0'}, {
                name: '',
                css: '',
                value: '研究性学习',
                instanceType: '210'
            }, {name: '', css: '', value: '创新成果', instanceType: '211'},
            {name: '', css: '', value: '优势学科竞赛', instanceType: '212'}, {
                name: '',
                css: '',
                value: '其他知识竞赛',
                instanceType: '213'
            }, {name: '', css: '', value: '考试成绩', instanceType: '214'},
            {name: '', css: '', value: '其他', instanceType: '215'}
        ],
        sxjkArr: [
            {name: '', css: 'active', value: '全部', instanceType: '0'}, {
                name: '',
                css: '',
                value: '体育竞赛',
                instanceType: '310'
            }, {name: '', css: '', value: '体育社团', instanceType: '311'},
            {name: '', css: '', value: '特长项目', instanceType: '312'}, {
                name: '',
                css: '',
                value: '基本情况',
                instanceType: '313'
            }, {name: '', css: '', value: '体质测试结果', instanceType: '314'},
            {name: '', css: '', value: '其他', instanceType: '315'}
        ],
        yssyArr: [
            {name: '', css: 'active', value: '全部', instanceType: '0'}, {
                name: '',
                css: '',
                value: '艺术比赛',
                instanceType: '410'
            }, {name: '', css: '', value: '艺术社团', instanceType: '411'},
            {name: '', css: '', value: '特长项目', instanceType: '412'}, {
                name: '',
                css: '',
                value: '其他',
                instanceType: '413'
            }
        ],
        shsjArr: [
            {name: '', css: 'active', value: '全部', instanceType: '0'}, {
                name: '',
                css: '',
                value: '社会实践',
                instanceType: '510'
            }, {name: '', css: '', value: '研学旅行', instanceType: '511'}
        ],
        tsxmArr: [
            {name: '', css: 'active', value: '全部', instanceType: '0'}, {
                name: '',
                css: '',
                value: '其他特色项目',
                instanceType: '610'
            }
        ],
        QBshow: true,
        SXPDshow: false,
        XYSPshow: false,
        SXJKshow: false,
        YSSYshow: false,
        SHSJshow: false,
        TSXMshow: false
    },

    lifetimes: {
        attached: function () {
            // 在组件实例进入页面节点树时执行
            this.resetCss(this.data.instanceTypeArr);
            wx.setStorageSync("howmany", 0)
            this.setData({
                page: 1,
                loadBoolean: true,
                hide_exampleList: true,
            })
            console.log('组件加载时将待处理实例集合加载进组件');
            util.showLoading();
            let _this = this;
            //获取教师写实
            var data = {
                //page：页码默认为1   pageSize：每页个数，默认20
                page: 1,
                pageSize: 10,
                dealType: '1',
            }
            util.getTeacherIndex(data).then(function (res) {
                //获取教师写实首页成功
                console.log('获取教师写实success----', res)
                if (res.data.code == 0) {
                    _this.setData({
                        exampleList: _this.handleShowName(res.data.info.data || [])
                    })
                } else if (res.data.code == 3003) {
                    _this.setData({
                        exampleList: [],
                    })
                } else {
                    util.showError(JSON.stringify(res.data.message))
                }
            })
        },
        detached: function () {
            // 在组件实例被从页面节点树移除时执行
        },
    },

    pageLifetimes: {
        // 组件所在页面的生命周期函数
        show: function () {
            //加载页面触发
            let listIndex = wx.getStorageSync("listIndex")
            let howmany = wx.getStorageSync('howmany')
            if (this.data.hide_exampleList) {
                this.data.exampleList.splice(listIndex, howmany);
            } else {
                this.data.examoleSearchList.splice(listIndex, howmany);
            }
            this.setData(this.data)
            wx.setStorageSync("howmany", 0)
        },
        hide: function () {
            // 页面被隐藏
        },
        resize: function (size) {
            // 页面尺寸变化
        }
    },


    methods: {
        //筛选获取教师写实实例集合   identification标识：筛选进来的需要带上标识identification=1，搜索进来的要带上标识等于2
        getTeacherWebIndex(identification) {
            let _this = this;
            console.log('点击筛选将待处理实例集合加载进组件');
            console.log('携带参数：dealType: 1  activityType:' + _this.data.activityType + '    instanceType:' + _this.data.instanceType,);

            var data = {
                //page：页码默认为1   pageSize：每页个数，默认20
                page: _this.data.page,
                pageSize: _this.data.pageSize,
                dealType: '1',
                activityType: _this.data.activityType,
                instanceType: _this.data.instanceType,
            }
            util.getTeacherIndex(data).then(function (res) {
                //获取教师写实首页成功
                console.log('获取教师写实success----', res)
                if (res.data.code == 0) {

                    let exampleList = _this.data.exampleList;
                    let arrData = res.data.info.data || []
                    if (arrData.length < _this.data.pageSize) {
                        _this.data.loadBoolean = false;
                    } else {
                        _this.data.loadBoolean = true;
                    }
                    if (_this.data.page == 1) {
                        exampleList = arrData
                        wx.stopPullDownRefresh()
                    } else {
                        for (let i = 0; i < arrData.length; i++) {
                            exampleList.push(arrData[i]);
                        }
                    }
                    _this.data.exampleList = _this.handleShowName(exampleList)
                    _this.setData(_this.data);
                } else if (res.data.code == 3003) {
                    if (_this.data.page == 1) {
                        _this.data.exampleList = [];
                    } else {
                        _this.data.loadBoolean = false;
                    }
                    _this.setData(_this.data);
                } else {
                    util.showError(JSON.stringify(res.data.message))
                }
            });
        },

        refreshData() {
            console.log("teacher11111111111111111111111")
            this.setData({
                page: 1
            })
            this.getTeacherWebIndex();
        },

        //教师处理写实
        dealRecord(rejectType, reason) {
            console.log('实例id：' + this.data.instanceId + '处理类型：' + this.data.dealType + '驳回类型为：' + rejectType + '驳回类型选择了其他时原因为：' + reason + '   处理实例下标为：' + this.data.exampleListIndex)
            let _this = this;
            var data = {
                //传输实例id和处理类型
                instanceId: _this.data.instanceId,
                dealType: _this.data.dealType,
                rejectType: rejectType,
                rejectReason: reason,
            }
            util.dealRecord(data).then(function (res) {
                //教师处理写实接口返回成功
                console.log('教师处理写实接口success----', res);
                if (res == 1) {
                    var arrExampleList = _this.data.exampleList;
                    if (_this.data.examoleSearchList.length > 0) {
                        _this.data.examoleSearchList.splice(_this.data.examoleSearchListIndex, 1);
                    } else {
                        arrExampleList.splice(_this.data.exampleListIndex, 1);
                    }
                    _this.setData(_this.data)

                    _this.triggerEvent('myevent')
                    wx.showToast({
                        title: '处理成功',
                        icon: 'success',
                        duration: 2000,
                        success() {
                            console.log('toast end');
                        },
                    });
                } else {
                    util.showError(JSON.stringify(res.data.message))
                }
            })
        },

        //加载更多
        on_LoadMore() {
            console.log('加载更多')
            let _page = this.data.page
            _page++;
            this.setData({
                page: _page
            })
            util.showLoading();
            this.getTeacherWebIndex()
        },

        //点击浏览图片
        onBrowse(e) {
            console.log('实例id：' + e.currentTarget.dataset.id)
            util.selectImg(e.currentTarget.dataset.id)
                .then(function (res) {
                    wx.previewImage({
                        current: 0,
                        urls: res,
                    });
                })
        },

        // 点击查看
        selectInfo(e) {
            let item = e.currentTarget.dataset.item;
            let activityType = item.activityType;
            let instanceType = item.instanceType;
            let instanceId = item.id;
            let listIndex = e.currentTarget.dataset.index;
            wx.setStorageSync("listIndex", listIndex);
            if (activityType == 1) {
                //思想品德
                if (instanceType == 110 || instanceType == 111) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/sxpd/from-sxdt/InstanceInfo?instanceId=' + instanceId   //跳转至党团，社团
                    })
                } else if (instanceType == 112) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/sxpd/from-gyhd/from-gyhd?instanceId=' + instanceId   //跳转至公益活动
                    })
                } else if (instanceType == 113) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/sxpd/from-zyfw/from-zyfw?instanceId=' + instanceId   //跳转至志愿服务
                    })
                } else if (instanceType == 114) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/sxpd/from-grry/from-grry?instanceId=' + instanceId   //跳转至个人荣誉
                    })
                } else if (instanceType == 115) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/sxpd/from-bljl/from-bljl?instanceId=' + instanceId   //跳转至不良记录
                    })
                } else if (instanceType == 116) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/sxpd/from-other/from-other?instanceId=' + instanceId   //跳转至其它
                    })
                }
            } else if (activityType == 2) {
                //学业水平
                if (instanceType == 210) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/xysp/xysp-yjxxx/xysp-yjxxx?instanceId=' + instanceId   //跳转至研究性学习
                    })
                } else if (instanceType == 211) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/xysp/xysp-cxcg/xysp-cxcg?instanceId=' + instanceId   //跳转至创新成果
                    })
                } else if (instanceType == 212) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/xysp/xysp-ysxkjs/xysp-ysxkjs?instanceId=' + instanceId   //跳转至优势学科竞赛
                    })
                } else if (instanceType == 213) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/xysp/xysp-qtzsjs/xysp-qtzsjs?instanceId=' + instanceId   //跳转至其它知识竞赛
                    })
                } else if (instanceType == 214) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/xysp/xysp-kscj/xysp-kscj?instanceId=' + instanceId   //跳转至考试成绩
                    })
                } else if (instanceType == 215) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/xysp/xysp-qt/xysp-qt?instanceId=' + instanceId   //跳转至其它
                    })
                }
            } else if (activityType == 3) {
                //身心健康
                if (instanceType == 310) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/sxjk/tyjs/tyjs?instanceId=' + instanceId   //跳转至体育竞赛
                    })
                } else if (instanceType == 311) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/sxjk/tyst/tyst?instanceId=' + instanceId   //跳转至体育社团
                    })
                } else if (instanceType == 312) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/sxjk/tytc/tytc?instanceId=' + instanceId   //跳转至体育特长
                    })
                } else if (instanceType == 313) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/sxjk/jbqk/jbqk?instanceId=' + instanceId   //跳转至基本情况
                    })
                } else if (instanceType == 314) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/sxjk/tcjg/tcjg?instanceId=' + instanceId   //跳转至 体测结果
                    })
                } else if (instanceType == 315) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/sxjk/qt/qt?instanceId=' + instanceId   //跳转至其它
                    })
                }
            } else if (activityType == 4) {
                //艺术素养
                if (instanceType == 410) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/yssy/ysbs/ysbs?instanceId=' + instanceId   //跳转至艺术比赛
                    })
                } else if (instanceType == 411) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/yssy/ystd/ystd?instanceId=' + instanceId   //跳转至艺术团队
                    })
                } else if (instanceType == 412) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/yssy/ystc/ystc?instanceId=' + instanceId   //跳转至艺术特长 
                    })
                } else if (instanceType == 413) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/yssy/qt/qt?instanceId=' + instanceId   //跳转至其它
                    })
                }
            } else if (activityType == 5) {
                //社会实践
                if (instanceType == 510) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/shsj/from-shsj/from-shsj?instanceId=' + instanceId   //社会实践
                    })
                } else if (instanceType == 511) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/shsj/from-yxlx/from-yxlx?instanceId=' + instanceId   //研学旅行
                    })
                }
            } else if (activityType == 6) {
                //特色项目
                if (instanceType == 610) {
                    wx.navigateTo({
                        url: '/pages/InstanceInfo/tsxm/from-tsjy/from-tsjy?instanceId=' + instanceId   //跳转至特色项目
                    })
                }
            }
        },

        // 点击确认
        confirm(e) {
            let _this = this;
            let index = e.currentTarget.dataset.index;
            let id = e.currentTarget.dataset.id;
            wx.showModal({
                title: '确认通过',
                content: '请确认已审核学生的写实记录',
                confirmText: '确定',
                cancelText: '取消',
                success({confirm}) {
                    if (confirm) {
                        console.log('确认')
                        _this.setData({
                            dealType: '1',
                            instanceId: id,
                        })
                        if (_this.data.examoleSearchList.length > 0) {
                            _this.setData({
                                examoleSearchListIndex: index,
                            })
                        } else {
                            _this.setData({
                                exampleListIndex: index
                            })
                        }
                        _this.dealRecord()

                    } else {
                        console.log('取消')
                    }
                },
                fail() {
                    console.log('fail');
                },
                complete() {
                    console.log('complete');
                },
            });
        },

        // 点击驳回
        reject(e) {
            let index = e.currentTarget.dataset.index;
            console.log("wcl______________________________")
            let _this = this;
            this.setData({
                grade_name: '--请选择--',
                reject_Boolean: false,
                bh_id: e.currentTarget.dataset.id,
            })
            if (_this.data.examoleSearchList.length > 0) {
                _this.setData({
                    examoleSearchListIndex: index,
                })
            } else {
                _this.setData({
                    exampleListIndex: index
                })
            }

        },

        // 点击驳回后点击取消
        cancel() {
            this.setData({
                reject_Boolean: true, select: false, input_Boolean: true,
            })
        },

        // 点击驳回后点击确定
        determine() {
            let _this = this;
            let name = _this.data.grade_name;
            let rejectTypeIndex = _this.data.rejectTypeIndex;
            let rejectType = 0;
            if (name != '--请选择--') {
                if (name == '其他') {
                    if (_this.data.reason == '') {
                        util.showError('驳回失败,请输入原因！')
                    } else {
                        wx.showModal({
                            title: '确认驳回',
                            content: '您确定驳回该学生的写实记录吗？',
                            confirmText: '确定',
                            cancelText: '取消',
                            success({confirm}) {
                                if (confirm) {
                                    rejectType = 25;
                                    _this.setData({
                                        reject_Boolean: true, select: false, input_Boolean: true,
                                        dealType: '2',
                                        instanceId: _this.data.bh_id,
                                    })
                                    _this.dealRecord(rejectType, _this.data.reason)
                                } else {
                                    console.log('取消')
                                }
                            },
                        });
                    }
                } else {
                    wx.showModal({
                        title: '确认驳回',
                        content: '您确定驳回该学生的写实记录吗？',
                        confirmText: '确定',
                        cancelText: '取消',
                        success({confirm}) {
                            if (confirm) {
                                if (rejectTypeIndex == 0) {
                                    rejectType = 21
                                } else if (rejectTypeIndex == 1) {
                                    rejectType = 22
                                } else if (rejectTypeIndex == 2) {
                                    rejectType = 23
                                } else if (rejectTypeIndex == 3) {
                                    rejectType = 24
                                }
                                _this.setData({
                                    reject_Boolean: true, select: false, input_Boolean: true,
                                    dealType: '2',
                                    instanceId: _this.data.bh_id,
                                })
                                _this.dealRecord(rejectType)
                            } else {
                                console.log('取消')
                            }
                        },
                    });
                }
            } else {
                util.showError('驳回失败，请选择驳回原因！')
            }
        },

        // 点击下拉列表
        bindShowMsg() {
            this.setData({
                select: !this.data.select
            })
        },

        // 选择元素
        mySelect(e) {
            console.log(e)
            var name = e.currentTarget.dataset.name
            let index = e.currentTarget.dataset.index;
            if (name == '其他') {
                this.setData({
                    reason: '',
                    input_Boolean: false
                })
            } else {
                this.setData({
                    input_Boolean: true
                })
            }
            this.setData({
                grade_name: name,
                rejectTypeIndex: index,
                select: false
            })
        },

        // 获取input中的值
        reasonKey(e) {
            this.setData({
                reason: e.detail.value,
            });
        },

        // 点击类型
        on_activity(e) {
            let index = e.currentTarget.dataset.index;
            let name = this.data.instanceTypeArr[index].name;
            this.setData({
                activityTypeString: name,
            })
            let arr = this.data.instanceTypeArr;
            let i = 0;
            for (; i < arr.length; i++) {
                arr[i].css = ''
            }
            this.data.instanceTypeArr[index].css = 'active';

            for (let j = 0; j < this.data.sxpdArr.length; j++) {
                this.data.sxpdArr[j].css = ''
            }
            this.data.sxpdArr[0].css = 'active';
            for (let j = 0; j < this.data.xyspArr.length; j++) {
                this.data.xyspArr[j].css = ''
            }
            this.data.xyspArr[0].css = 'active';
            for (let j = 0; j < this.data.sxjkArr.length; j++) {
                this.data.sxjkArr[j].css = ''
            }
            this.data.sxjkArr[0].css = 'active';
            for (let j = 0; j < this.data.yssyArr.length; j++) {
                this.data.yssyArr[j].css = ''
            }
            this.data.yssyArr[0].css = 'active';
            for (let j = 0; j < this.data.shsjArr.length; j++) {
                this.data.shsjArr[j].css = ''
            }
            this.data.shsjArr[0].css = 'active';
            for (let j = 0; j < this.data.tsxmArr.length; j++) {
                this.data.tsxmArr[j].css = ''
            }
            this.data.tsxmArr[0].css = 'active';

            this.data.activityType = this.data.instanceTypeArr[index].activityType;
            this.data.instanceType = '0';
            if (name == "全部") {
                this.setData({
                    QBshow: true, SXPDshow: false, XYSPshow: false,
                    SXJKshow: false, YSSYshow: false, SHSJshow: false, TSXMshow: false,
                })
            } else if (name == "思想品德") {
                this.setData({
                    QBshow: false, SXPDshow: true, XYSPshow: false,
                    SXJKshow: false, YSSYshow: false, SHSJshow: false, TSXMshow: false,
                })
            } else if (name == "学业水平") {
                this.setData({
                    QBshow: false, SXPDshow: false, XYSPshow: true,
                    SXJKshow: false, YSSYshow: false, SHSJshow: false, TSXMshow: false,
                })
            } else if (name == "身心健康") {
                this.setData({
                    QBshow: false, SXPDshow: false, XYSPshow: false,
                    SXJKshow: true, YSSYshow: false, SHSJshow: false, TSXMshow: false,
                })
            } else if (name == "艺术素养") {
                this.setData({
                    QBshow: false, SXPDshow: false, XYSPshow: false,
                    SXJKshow: false, YSSYshow: true, SHSJshow: false, TSXMshow: false,
                })
            } else if (name == "社会实践") {
                this.setData({
                    QBshow: false, SXPDshow: false, XYSPshow: false,
                    SXJKshow: false, YSSYshow: false, SHSJshow: true, TSXMshow: false,
                })
            } else if (name == "特色项目") {
                this.setData({
                    QBshow: false, SXPDshow: false, XYSPshow: false,
                    SXJKshow: false, YSSYshow: false, SHSJshow: false, TSXMshow: true,
                })
            }
            this.setData(this.data)
        },


        //点击思想品德实例中的元素
        on_sxpd_example(e) {
            var me = this;
            console.log(e.currentTarget.dataset.index)
            let index = e.currentTarget.dataset.index;
            let arr = me.data.sxpdArr;
            let i = 0;
            for (; i < arr.length; i++) {
                arr[i].css = ''
            }
            arr[index].css = 'active';
            // this.data.instanceTypeString=arr[index].value
            // this.data.instanceType=e.currentTarget.dataset.instancetype;
            me.setData({
                instanceTypeString: arr[index].value,
                sxpdArr: arr,
                instanceType: e.currentTarget.dataset.instancetype
            })
            // me.setData( instanceTypeString,this.data.instanceType);
        },

        //点击学业水平实例中的元素
        on_xysp_example(e) {
            var me = this;
            console.log(e.currentTarget.dataset.index)
            let index = e.currentTarget.dataset.index;
            let arr = me.data.xyspArr;
            let i = 0;
            for (; i < arr.length; i++) {
                arr[i].css = ''
            }
            arr[index].css = 'active';
            this.data.instanceTypeString = arr[index].value,
                this.data.instanceType = e.currentTarget.dataset.instanceType;
            me.setData(me.data);
        },

        //点击身心健康实例中的元素
        on_sxjk_example(e) {
            var me = this;
            console.log(e.currentTarget.dataset.index)
            let index = e.currentTarget.dataset.index;
            let arr = me.data.sxjkArr;
            let i = 0;
            for (; i < arr.length; i++) {
                arr[i].css = ''
            }
            arr[index].css = 'active';
            this.data.instanceTypeString = arr[index].value,
                this.data.instanceType = e.currentTarget.dataset.instanceType;
            me.setData(me.data);
        },

        //点击艺术素养实例中的元素
        on_yshy_example(e) {
            var me = this;
            console.log(e.currentTarget.dataset.index)
            let index = e.currentTarget.dataset.index;
            let arr = me.data.yssyArr;
            let i = 0;
            for (; i < arr.length; i++) {
                arr[i].css = ''
            }
            arr[index].css = 'active';
            this.data.instanceTypeString = arr[index].value,
                this.data.instanceType = e.currentTarget.dataset.instanceType;
            me.setData(me.data);
        },

        //点击社会实践实例中的元素
        on_shsj_example(e) {
            var me = this;
            console.log(e.currentTarget.dataset.index)
            let index = e.currentTarget.dataset.index;
            let arr = me.data.shsjArr;
            let i = 0;
            for (; i < arr.length; i++) {
                arr[i].css = ''
            }
            arr[index].css = 'active';
            this.data.instanceTypeString = arr[index].value,
                this.data.instanceType = e.currentTarget.dataset.instanceType;
            me.setData(me.data);
        },

        //点击特色项目实例中的元素
        on_tsxm_example(e) {
            var me = this;
            console.log(e.currentTarget.dataset.index)
            let index = e.currentTarget.dataset.index;
            let arr = me.data.tsxmArr;
            let i = 0;
            for (; i < arr.length; i++) {
                arr[i].css = ''
            }
            arr[index].css = 'active';
            this.data.instanceTypeString = arr[index].value,
                this.data.instanceType = e.currentTarget.dataset.instanceType;
            me.setData(me.data);
        },

        //搜索
        on_search(e) {
            var arr = [];
            util.showLoading();
            this.getAllData(e.detail.value, 1, arr)
        },


        getAllData(value, page, arr) {
            let _this = this;
            var data = {
                //page：页码默认为1   pageSize：每页个数，默认20
                page: page,
                pageSize: 20,
                dealType: '1',
            }
            util.getTeacherIndex(data).then(function (res) {
                //获取教师写实首页成功
                console.log('使用获取教师写实接口查询所有list成功----', res)
                if (res.data.code == 0) {
                    let arrData = res.data.info.data || [];
                    for (let i = 0; i < arrData.length; i++) {
                        arr.push(arrData[i]);
                    }
                    if (arrData.length < _this.data.pageSize) {
                        _this.queryData(value, arr);
                    } else {
                        page++
                        _this.getAllData(value, page, arr)
                    }
                } else {
                    util.showError(JSON.stringify(res.data.message))
                }
            })
        },

        queryData(value, arr) {
            let _this = this;
            console.log('搜索结果：' + value)
            var str = '^(.*' + value + '.*)$'
            var re = new RegExp(str);  //正则表达式需要用RegExp()转换一下
            let i = 0;
            let student_Name, activity_TypeString, instance_TypeString, item_Name = '';
            let examoleArr = _this.data.examoleSearchList;
            let inn = 0;
            examoleArr = [];
            for (; i < arr.length; i++) {
                student_Name = arr[i].userName
                activity_TypeString = arr[i].activityTypeString
                instance_TypeString = arr[i].instanceTypeString
                item_Name = arr[i].showName
                if (!(value == '')) {
                    if (re.test(student_Name) || re.test(activity_TypeString) || re.test(instance_TypeString) || re.test(item_Name)) {
                        examoleArr[inn] = arr[i]
                        inn++
                    }
                }
            }
            if (examoleArr.length > 0) {
                _this.data.listHide = 1
            } else {
                _this.data.listHide = 0
            }
            _this.data.examoleSearchList = _this.handleShowName(examoleArr);
            util.hideLoading();
            _this.setData(_this.data);
        },

        //处理标题文字
        handleShowName(exampleList) {
            for (var index in exampleList) {
                let showName = exampleList[index].showName
                if (showName.length > 10) {
                    exampleList[index].showName = showName.substring(0, 10) + "..."
                }
            }
            return (exampleList)
        },


        // 筛选
        toggleFilterModal(e) {
            console.log(e)
            let show = this.data.filterModal.show
            this.setData({
                'filterModal.show': !show,
                hide_exampleList: false,
            })
        },

        // 筛选确定
        on_toggleFilterModal(e) {
            console.log(e)
            let show = this.data.filterModal.show

            this.setData({
                'filterModal.show': !show,
                screenYesOrNo: true,
                hide_exampleList: true,
                page: 1
            })
            util.showLoading();
            this.getTeacherWebIndex(1)
        },

        // 重置CSS
        resetCss(arr) {
            for (let i = 0; i < arr.length; i++) {
                arr[i].css = ''
            }
            ;
            arr[0].css = 'active';
        },
        //清除CSS
        eliminateCss(arr) {
            for (let i = 0; i < arr.length; i++) {
                arr[i].css = ''
            }
            ;
        },

        //取消筛选
        screenCancel() {
            this.resetCss(this.data.instanceTypeArr);
            this.setData({
                screenYesOrNo: false,
                QBshow: true, SXPDshow: false, XYSPshow: false,
                SXJKshow: false, YSSYshow: false, SHSJshow: false, TSXMshow: false,
                activityType: 0,
                instanceType: 0,
                activityTypeString: '全部',
                instanceTypeString: '全部',
                page: 1,
            })
            util.showLoading();
            this.getTeacherWebIndex()
        },

        //搜索
        toggleSearchModal(e) {
            console.log(e)
            let show = this.data.searchModal.show
            this.setData({
                'searchModal.show': !show,
                examoleSearchList: [],
                hide_exampleList: false,
                listHide: 0,
                examoleSearchListIndex: -1,
                activityType: 0,
                instanceType: 0,
            })
        },

        //搜索取消
        on_toggleSearchModal(e) {
            console.log(e)
            let show = this.data.searchModal.show
            this.setData({
                'searchModal.show': !show,
                examoleSearchList: [],
                hide_exampleList: true,
                listHide: 0,
                examoleSearchListIndex: -1,
                activityType: 0,
                instanceType: 0,
            })
            util.showLoading();
            this.getTeacherWebIndex()
        },
    },
});
